What is Bayesian Deconvolution and Why Is It Important?
In the real world, X-ray fluorescence is preferred when analyzing heterogenous materials such as paintings. These materials are quite complex, and quantification in the traditional sense is impossible. In these cases, Bayesian deconvolution can be performed in the Artax software to analyze, in a semi-quantitative way, these materials.

Bayesian inference were initially formulated by Thomas Bayes in the 18th century and further refined over two centuries. For most of that time, application of Bayesian methods was limited due to their time intensive calculations. Bayesian methods added two critical components in the 1980. The Markov chain, a random walk iteration method, and Monte Carlo algorithms which require random input. These, combined with the radio increase in power and affordability of computers, enabled the widespread application of Bayesian methods.

A popular example of Bayesian methods is the Monty Hall problem. In the Monty Hall show, a contestant was offered three doors to choose from. Behind one was a prize, behind the other two was a goat. The contestant selects a door. Then Monty Hall opens up a door to reveal a goat, leaving two options left. Monty Hall gives the contestant the opportunity to switch their choice, or stay with their first pick. The odds that a prize was behind a specific door when the game began was 1/3, or 33%. The contestant selects door #1. Monte Hall opens up door #2 to reveal a goat. There are now two doors left, what are the respective odds that a prize is behind door #1, or door #3?

First, we have our initial set of probabilities when the game starts:

P(#1) = P(#2) = P(#3) = 1/3 = 0.33

Because each door has an equal chance of containing the prize, it is a 33% chance that the contestant makes the correct selection the first time. Next, we introduce Monty Hall’s subjective prior: O = The event in which Monty Hall reveals that there is no prize between #2. We then calculate the possible probabilities of the prize being behind each door after this information is obtained. There are rules that structure these probabilities. First, Monty Hall cannot open up the door you selected first, otherwise the game would end with no tension. Second, Monty Hall must reveal at least one goat, or else the game would end shortly as well. As such, we calculate the probabilities of each potential conclusion:

P(O|#1) = 0.5 - This door has the prize, Monty Hall can open up #2 or #3 at will
P(O|#2) = 0 - Monty Hall has already shown us that a goat is behind this door
P(O|#3) = 1 - Monty Hall must open #2 first because the prize is here.
Then, the probability of O can be calculated:
P(O) = P(#1)P(O|#1) +P(#2)P(O|#2) + P(#3)P(O|#3)
P(O) = 0.33 * 0.5 + 0.33 * 0 + 0.33 * 1
P(O) = 0.5

With these probabilities calculated, we can then use Bayes theorem to calculate the probability that the prize lies behind door #1 (the contestants choice):

P(#1|O) = P(#1)P(O|#1) / P(O)
P(#1|O) = 0.33 * 0.5 / 0.5
P(#1|O) = 0.33

And we can then calculate the probability that the prize lies behind door #3:

P(#3|O) = P(A)P(O|A) / P(O)
P(31|O) = 0.33 * 1 / 0.5
P(#3|O) = 0.66

The answer, surprisingly to many, is a 3 3% probability for the prize behind door #1 and 66% for door #3. This is because the contestant choose door #1 when the odds were 33%. When Monte Hall demonstrated that door number #2 had nothing but a goat, he altered the odds for door #3, but not for door #1 - Monte Hall will not end the the game early by revealing the contestants door. As such, the new information causes us to recalculate the new, posterior probability after a subjective prior (Monte Hall) is introduced. For the contestant, they are better off switching their choice to door #3, it will yield a prize 66% of the time, while their original choice will yield a goat 66% of the time. This problem could have interesting implications for which grid units archaeologists choose to excavate in the field when trying to trace a specific feature.

A more cogent example is in drug/disease tests. Say a person contains a gene for early Alzheimer's onset. The test is 99% accurate - it will only give false positives 1% of the time. It is also 99% likely to identify the person as lacking the gene - only 1% of tests are false positives. Finally, the gene is rare, it has a prevalence of only 0.5% in the population. If you take the genetic test, and you test positive for the gene, what is the chance you actually have the gene for the early onset of Alzheimer's? Once again, Bayesian methods shake expectations. The subjective prior in this case is the prevalence, 0.5% of the population has the rare gene. We express it using Bayes theorem:

P(A|B) = P(B|A)P(A) / P(B)
Where P(B) = P(B|A)P(A) + P(B|~A)P(~A)
P(B) = 0.99*0.005 + 0.01*0.995 = 0.0149
P(A|B) = (0.99 * 0.005) / 0.0149
P(A|B) = 0.33

...and find that the answer is about 33.3% percent. That is to say, testing positive for a gene, despite the high accuracy of the test, means that there is still a 66% chance you do not have the gene. You are considerably more likely than the general population, but the odds are still in your favor. The application of Bayes theorem is particularly important in medical tests. The Alzheimer's example above is why random drug tests for rare drugs is not encouraged - for every employee who is an addict, two will lose their jobs unjustly. It is also important for medical screenings. Mammograms gave far more false positives than true positives, leading to expensive additional tests for many women. This is why, in 2009, mammograms were not recommended for people under 50 unless their family has a history of great cancer (in which case the prevalence rate, or subjective prior, is much higher).

All this is to say that Bayesian inference is complex. However, when used appropriately, it can help understand reality. Artax provides a medium to understand this. However, it requires input from humans. As much as we would like, we cannot simply use a computer to identify all of our elements. That requires pattern recognition, and it is a bridge too far for computers. This actually underlies one of the chief weaknesses of quantitative calibrations used on the Tracer and the Titan - the introduction of a new, unaccounted-for element can throw everything off. That is not the case with Bayesian deconvolution - it actually thrives in those conditions.

Think back to the Monty Hall problem. You have an initial set of probabilities, three doors. This is your prior probability, and it is 33.33% for each door. Then Mr. Monty Hall adds new information by taking away a door. You consider the effects of this information and what it means for each door. Then you calculate the posterior probability for each door, and find that you will likely be much richer if you switch your answer. The same basic process happens with elemental spectra. The initial spectrum is a prior probability. The elements selected by the user will act as the new information, and the Artax software will calculate the posterior probability - or number of net photons per element in the spectra.

This process deco volutes the quite convoluted spectra. You can think of it as pulling the elemental peaks apart from one another and correcting for inter-elemental effects. The product then is a more quantitative, but still subjective, measure of atomic data. This is because the light and filter settings you choose in your original analysis bias the occurrence of elements. When you use the yellow filter, for example, you suppress light elements like silica and increase your detection limit for trace elements like strontium.